package com.xhtt.modules.task.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xhtt.common.exception.RRException;
import com.xhtt.modules.cfg.entity.*;
import com.xhtt.modules.cfg.service.*;
import com.xhtt.modules.task.entity.TaskShipPlan;
import com.xhtt.modules.task.entity.TaskShipPlanProduct;
import com.xhtt.modules.task.entity.TaskShipTask;
import com.xhtt.modules.task.entity.TaskShipTaskProdStep;
import com.xhtt.modules.task.service.TaskShipPlanProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class TaskUtils {
    @Autowired
    private CfgPotInfoService cfgPotInfoService;
    @Autowired
    private CfgTubeInfoService cfgTubeInfoService;
    @Autowired
    private CfgPumpInfoService cfgPumpInfoService;
    @Autowired
    private CfgHoseInfoService cfgHoseInfoService;
    @Autowired
    private TaskShipPlanProductService taskShipPlanProductService;
    @Autowired
    private CfgTaskSubService taskSubService;
    @Autowired
    private CfgTaskInfoService taskInfoService;

    public String getRfid(int type, int typeId) {
        String rfid = "";
        if (type == 1)//罐
        {
            CfgPotInfo pot = cfgPotInfoService.getOne(new LambdaQueryWrapper<CfgPotInfo>().eq(CfgPotInfo::getId, typeId).select(CfgPotInfo::getRfid));
            rfid = null == pot ? "" : pot.getRfid();
        } else if (type == 2)//硬管
        {
            CfgTubeInfo tube = cfgTubeInfoService.getOne(new LambdaQueryWrapper<CfgTubeInfo>().eq(CfgTubeInfo::getId, typeId).select(CfgTubeInfo::getRfid));
            rfid = null == tube ? "" : tube.getRfid();
        } else if (type == 3)//泵
        {
            CfgPumpInfo pump = cfgPumpInfoService.getOne(new LambdaQueryWrapper<CfgPumpInfo>().eq(CfgPumpInfo::getId, typeId).select(CfgPumpInfo::getRfid));
            rfid = null == pump ? "" : pump.getRfid();
        } else if (type == 5)//软管
        {
            CfgHoseInfo hose = cfgHoseInfoService.getOne(new LambdaQueryWrapper<CfgHoseInfo>().eq(CfgHoseInfo::getId, typeId).select(CfgHoseInfo::getRfid));
            rfid = null == hose ? "" : hose.getRfid();
        }
        return rfid;
    }

}
